package com.aaa.web.controller.carhouse;

import com.aaa.entity.repair.BackEntrepot;
import com.aaa.web.commons.NewCarQuery;
import com.aaa.web.service.icarhouseservice.IPartsHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @program: battery
 * @description: 配件
 * @author: 王璐
 * @create: 2018-12-22 08:35
 **/
@Controller
@RequestMapping("/partsHouse")
public class PartsHouseController {
    /**
     * 自动注入
     */
    @Autowired
    private IPartsHouseService service;

    /**
     * 进入配件仓库界面
     * @return
     */
    @RequestMapping("/getPartsPage")
    public String getNewCarPage(){
        return "views/webhtml/house/parts";
    }

    /**
     * 配件仓库的数据显示
     * @param query  查询的字段，包括门店ID
     * @return
     */
    @RequestMapping("/getAllParts")
    @ResponseBody
    public Map getAllParts(NewCarQuery query) {
        return service.getAllParts(query);
    }

    /**
     * 查询新车仓库的数据显示
     * @param query  查询的字段，包括门店ID
     * @return
     */
    @RequestMapping("/selectParts")
    @ResponseBody
    public Map selectParts(NewCarQuery query, BackEntrepot backEntrepot) {

        return service.selectParts(query,backEntrepot);
    }

    /**
     * 添加
     * @param backEntrepot
     * @return
     */
    @RequestMapping("/addParts")
    @ResponseBody
    public int addParts(BackEntrepot backEntrepot){
        return service.addParts(backEntrepot);
    }

    /**
     * 补货
     * @param goodsName
     * @param goodsQuantity
     * @return
     */
    @RequestMapping("/addOneTypeParts")
    @ResponseBody
    public int addOneTypeParts(String goodsName, int goodsQuantity,double goodsCost){
        return service.addOneTypeParts(goodsName,goodsQuantity,goodsCost);
    }

    /**
     * 编辑
     * @param goodsName
     * @return
     */
    @RequestMapping("/editOneTypeParts")
    @ResponseBody
    public int editOneTypeCar(String goodsName,String oldGoodsName){
        return service.editOneTypeParts(goodsName,oldGoodsName);
    }
}
